{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "打开文件\n",
      "操作文件\n",
      "关闭文件\n",
      "dfgdfg\n"
     ]
    }
   ],
   "source": [
    "from abc import abstractmethod,ABCMeta\n",
    "\n",
    "class iohandler(metaclass=ABCMeta):\n",
    "    @abstractmethod\n",
    "    def open(self,name):\n",
    "        pass\n",
    "    @abstractmethod\n",
    "    def deal(self,change):\n",
    "        pass\n",
    "    @abstractmethod\n",
    "    def close(self):\n",
    "        pass\n",
    "    def demo(self):\n",
    "        print('keyi')\n",
    "    def process(self,name,change):\n",
    "        self.open(name)\n",
    "        self.deal(change)\n",
    "        self.close()\n",
    "\n",
    "class filehandler(iohandler):\n",
    "    def open(self,name):\n",
    "        print('打开文件')\n",
    "    def deal(self,change):\n",
    "        print('操作文件')\n",
    "    def close(self):\n",
    "        print('关闭文件')\n",
    "    \n",
    "    def demo(self):\n",
    "        print('dfgdfg')\n",
    "obj=filehandler()\n",
    "obj.process('fujun.txt',23)\n",
    "obj.demo()\n",
    "        \n",
    "        "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.1"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
